﻿<script language = "javascript"> 
function C5SLLC_SetDataTypeLen(ddl,target,hidden) {
	var lenBox = document.getElementById(target);
	var hiddenField = document.getElementById(hidden);

	switch(ddl.value) {
		case "int" :
			lenBox.value = 4;
			hiddenField.value = 4;
			lenBox.disabled = true;
			break;
		case "tinyint" :
			lenBox.value = 1;
			hiddenField.value = 1;
			lenBox.disabled = true;
			break;
		case "smallint" :
			lenBox.value = 2;
			hiddenField.value = 2;
			lenBox.disabled = true;
			break;
		case "bigint" :
			lenBox.value = 8;
			hiddenField.value = 8;
			lenBox.disabled = true;
			break;
		case "nchar" :
			lenBox.value = 10;
			hiddenField.value = 10;
			lenBox.disabled = false;
			break;
		case "char" :
			lenBox.value = 10;
			hiddenField.value = 10;
			lenBox.disabled = false;
			break;
		case "nvarchar" :
			lenBox.value = 50;
			hiddenField.value = 50;
			lenBox.disabled = false;
			break;
		case "varchar" :
			lenBox.value = 50;
			hiddenField.value = 50;
			lenBox.disabled = false;
			break;
		case "ntext" :
			lenBox.value = 8;
			hiddenField.value = 8;
			lenBox.disabled = true;
			break;
		case "text" :
			lenBox.value = 16;
			hiddenField.value = 16;
			lenBox.disabled = true;
			break;
		case "float" :
			lenBox.value = 8;
			hiddenField.value = 8;
			lenBox.disabled = true;
			break;
		case "real" :
			lenBox.value = 4;
			hiddenField.value = 4;
			lenBox.disabled = true;
			break;
		case "money" :
			lenBox.value = 8;
			hiddenField.value = 8;
			lenBox.disabled = true;
			break;
		case "smallmoney" :
			lenBox.value = 4;
			hiddenField.value = 4;
			lenBox.disabled = true;
			break;
		case "datetime" :
			lenBox.value = 8;
			hiddenField.value = 8;
			lenBox.disabled = true;
			break;
		case "smalldatetime" :
			lenBox.value = 4;
			hiddenField.value = 4;
			lenBox.disabled = true;
			break;
		case "bit" :
			lenBox.value = 1;
			hiddenField.value = 1;
			lenBox.disabled = true;
			break;
		case "uniqueidentifier" :
			lenBox.value = 16;
			hiddenField.value = 16;
			lenBox.disabled = true;
			break;
		case "decimal" :
			lenBox.value = 9;
			hiddenField.value = 9;
			lenBox.disabled = true;
			break;
		case "numeric" :
			lenBox.value = 4;
			hiddenField.value = 4;
			lenBox.disabled = true;
			break;
	}
	
}
function C5SLLC_CheckMaxScale(ddlScale,target) {

	var ddlPrec = document.getElementById(target);
	if(eval(ddlScale.value) > eval(ddlPrec.value)) {
		alert("[SCALEERROR]");
		ddlScale.selectedIndex = ddlPrec.selectedIndex + 1;
	}
}
</script>
